/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "userMessages")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UserMessages.findAll", query = "SELECT u FROM UserMessages u"),
    @NamedQuery(name = "UserMessages.findByMessageIdmessage", query = "SELECT u FROM UserMessages u WHERE u.messageIdmessage = :messageIdmessage"),
    @NamedQuery(name = "UserMessages.findByStatus", query = "SELECT u FROM UserMessages u WHERE u.status = :status")})
public class UserMessages implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "message_idmessage")
    private Integer messageIdmessage;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "status")
    private String status;
    @JoinColumn(name = "User_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User userid;
    @JoinColumn(name = "message_idmessage", referencedColumnName = "idMessage", insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Message message;

    public UserMessages() {
    }

    public UserMessages(Integer messageIdmessage) {
        this.messageIdmessage = messageIdmessage;
    }

    public UserMessages(Integer messageIdmessage, String status) {
        this.messageIdmessage = messageIdmessage;
        this.status = status;
    }

    public Integer getMessageIdmessage() {
        return messageIdmessage;
    }

    public void setMessageIdmessage(Integer messageIdmessage) {
        this.messageIdmessage = messageIdmessage;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public User getUserid() {
        return userid;
    }

    public void setUserid(User userid) {
        this.userid = userid;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (messageIdmessage != null ? messageIdmessage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserMessages)) {
            return false;
        }
        UserMessages other = (UserMessages) object;
        if ((this.messageIdmessage == null && other.messageIdmessage != null) || (this.messageIdmessage != null && !this.messageIdmessage.equals(other.messageIdmessage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.UserMessages[ messageIdmessage=" + messageIdmessage + " ]";
    }
    
}
